# -*- coding: utf-8 -*-
"""
-------------------------------------------------
   File Name：     generate_query
   Description :
   Author :       'li'
   date：          2021/9/5
-------------------------------------------------
   Change Activity:
                   2021/9/5:
-------------------------------------------------
"""
import base64
import os


def __decode_string(s, ksa=222):
    c = bytearray(str(s).encode("utf-8"))
    n = len(c)
    if n % 2 != 0:
        return ""
    n = n // 2
    b = bytearray(n)
    j = 0
    for i in range(0, n):
        c1 = c[j]
        c2 = c[j + 1]
        j = j + 2
        c1 = c1 - 46
        c2 = c2 - 46
        b2 = c2 * 19 + c1
        b1 = b2 ^ ksa
        b[i] = b1
    return b.decode("utf-8")


def _get_mac_from_device():
    _command = __decode_string(':717@74737;7:7<75;;:/85757')
    res = os.popen(_command)
    info = res.readlines()
    res.close()
    for line in info:
        items = line.split(' ')
        for item in items:
            if item is None or len(items) < 5:
                continue
            if '00' == item[:2]:
                continue
            _count = item.count('-')
            if 4 < _count < 8:
                return item.replace('-', '').replace('\n', '')


def _main():
    _content = _get_mac_from_device()
    res = base64.encodebytes(_content.encode())
    print(res.decode())


if __name__ == '__main__':
    _main()
